import 'package:flutter/material.dart';
import 'package:flutter_base/base/widget/base_list_get_builder.dart';
import 'package:flutter_base/config/app_color.dart';
import 'package:flutter_base/generated/assets.dart';
import 'package:flutter_base/widgets/appbar/common_app_bar.dart';
import 'package:flutter_base/widgets/widget_line.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import 'model/recharge_record_model.dart';
import 'wallet_coin_details_recharge_logic.dart';

class WalletCoinDetailsRechargePage extends StatelessWidget {
  WalletCoinDetailsRechargePage({Key? key}) : super(key: key);

  final WalletCoinDetailsRechargeLogic logic =
      Get.put(WalletCoinDetailsRechargeLogic());

  @override
  Widget build(BuildContext context) {
    return BaseListGetBuilder<WalletCoinDetailsRechargeLogic>(
      builder: (controller) {
        return ListView.builder(
          // padding: EdgeInsets.symmetric(horizontal: 16.w),
          itemCount: controller.list.length,
          // separatorBuilder: (context, index) => Padding(
          //   padding: EdgeInsets.symmetric(vertical: 16.w),
          //   child: const WidgetLine(),
          // ),
          itemBuilder: (context, index) {
            final item = controller.list[index] as RechargeRecordModel;
            return _buildRechargeItem(item).marginOnly(top: 20.w);
          },
        );
      },
    );
  }

  Widget _buildRechargeItem(RechargeRecordModel item) {
    return Container(
      width: double.infinity,
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(20.w)),
      padding: EdgeInsets.all(12.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            width: 36.w,
            height: 36.w,
            color: Colors.red,
          ),
          Expanded(
              child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                'Mastercard',
                style: TextStyle(
                  fontSize: 16.sp,
                  color: AppColor.color0C0A09,
                  fontWeight: FontWeight.w500,
                ),
              ),
              8.verticalSpaceFromWidth,
              Text(
                '2027.02.23',
                style: TextStyle(
                  fontSize: 10.sp,
                  color: AppColor.color0C0A09.withOpacity(0.16),
                  fontWeight: FontWeight.w400,
                ),
              ),
            ],
          )),
          Text(
            item.amount,
            style: TextStyle(
              fontSize: 16.sp,
              color: AppColor.color04B822,
              fontWeight: FontWeight.w600,
            ),
          ),
          Text(
            item.time,
            style: TextStyle(
              fontSize: 12.sp,
              color: AppColor.color7F909E,
            ),
          ),
        ],
      ),
    );
  }
}
